package com.qdsgjsfk.vision.ui;

import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.widget.RelativeLayout;

import com.qdsgjsfk.vision.base.BaseActivity;
import com.qdsgjsfk.vision.ui.fragment.CollectStudentListFragment;

import com.qdsgjsfk.vision.R;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by HP on 2018/10/7.
 */

public class CollectStudentListActivity extends BaseActivity {

    @BindView(R.id.timeline_tablayout)
    TabLayout mTabLayout;
    @BindView(R.id.timeline_viewpager)
    ViewPager mViewPager;

    @BindView(R.id.title)
    RelativeLayout title;



    String taskId,className,classId,orgId;
    int prefix;

    public static int REQUEST_CODE_SCAN = 1;




    @Override
    protected void initViews() {
        mViewPager.setAdapter(new StudentListAdapter(this, getSupportFragmentManager()));
        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
        mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

        mViewPager.setCurrentItem(0);
        mTabLayout.getTabAt(0).select();
        title.bringToFront();
    }

    @Override
    protected void initData() {
        classId = getIntent().getStringExtra("classId");
        orgId = getIntent().getStringExtra("orgId");
        taskId = getIntent().getStringExtra("taskId");
        prefix= getIntent().getIntExtra("prefix",-1);
        className = getIntent().getStringExtra("className");
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_collect_student_list;
    }


    class StudentListAdapter extends FragmentPagerAdapter {
        private static final int PAGE_COUNT = 3;

        private Context mContext;

        public StudentListAdapter(Context context, FragmentManager fm) {
            super(fm);
            this.mContext = context;
        }

        @Override
        public Fragment getItem(int position) {
            String type;
            switch (position) {
                case 0:
                    type = "";
                    break;
                case 1:
                    type = "0";
                    break;
                case 2:
                    type = "1";
                    break;
                default:
                    type ="";
                    break;
            }
            return CollectStudentListFragment.newInstance(type, classId,taskId);
        }

        @Override
        public int getCount() {
            return PAGE_COUNT;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "全部";
                case 1:
                    return "未采集";
                case 2:
                    return "已采集";
                default:
                    return "";
            }
        }

    }



    @OnClick(R.id.tv_check)
    void tv_check(){
        Bundle bundle = new Bundle();
        bundle.putString("classId",classId);
        bundle.putInt("type",0);
        startActivity( FaceCheckActivity.class,bundle);
    }




}
